import { request } from '@/utils/request'
import { getCurrentOrganizationId } from '@/utils/util.js'
// 当前租户ID
// const organizationId = getCurrentOrganizationId();
const organizationId = 2;
// portal门户页面组件配置列表
export function getPersonalConfig() {
  return request({
    url: `/api/v1/${organizationId}/personal-configs/user`,
    method: 'get',
  })
}
export function requestIcon(params) {
  return request({
    // url: `/portal/v1/${organizationId}/funs/requestIcon?${params}`,
    url: `/api/v1/${organizationId}/funs/requestIcon?${params}`,
    method: 'get',
    headers: {
      "Content-Type": "image/png"
    },
    responseType: 'arraybuffer'
  })
}
export function quickEntrys(params) {
  return request({
    url: `/api/v1/${organizationId}/quick-entrys/requestIcon?${params}`,
    method: 'get',
    headers: {
      "Content-Type": "image/png"
    },
    responseType: 'arraybuffer'
  })
}
// 根据接口返回的dataUrl获取各个模块的数据
export function getComponentDataList(url) {
  url = `/api${url.replace('{organizationId}', organizationId)}`
  return request({
    url,
    method: 'get',
  })
}
export function getChartDataList(url) {
  url = `/api${url.replace('{organizationId}', organizationId)}`
  return request({
    url,
    method: 'get',
  })
}
// 获取待办区数据
// export function getToDoDataList (url, data = {}) {
//   url = `/portal${url.replace('{organizationId}', organizationId)}`
//   return request({
//     url,
//     method: 'post',
//     data
//   })
// }
export function getToDoDataList(data = {}) {
  return request({
    url: `/api/v1/${organizationId}/todos/page`,
    method: 'post',
    data
  })
}
// 工作区模块编辑后提交接口    
//2022-3-11  接口通____________________________________________
export function setPersonalConfig(method, data) {
  return request({
    url: `/api/v1/${organizationId}/personal-configs`,
    method,
    data,
  })
}
// 调用功能区查询接口获取分类标识
export function getCategoryFromFuns() {
  return request({
    url: `/api/v1/${organizationId}/funs?name=&size=1000`,
    method: 'get',
  })
}